﻿CREATE PROC dbo.spObtenEstudios(  
@pnIdLaboratorio    INT,  
@pnIdEstudio  INT,     
@psNombreEstudio VARCHAR(200)   
)    
AS    
BEGIN    
 -- SET NOCOUNT ON added to prevent extra result sets from    
 -- interfering with SELECT statements.    
 SET NOCOUNT ON;    
    
 IF @psNombreEstudio = ''    
  SET @psNombreEstudio = NULL;    
    
 SELECT e.IdLaboratorio, e.IdEstudio,e.NombreEstudio, e.EsGenerico, e.Precio  
 FROM dbo.CatEstudio (NOLOCK) e  
 WHERE (e.NombreEstudio LIKE '%' + @psNombreEstudio + '%' OR @psNombreEstudio IS NULL)    
 AND  (e.IdEstudio = @pnIdEstudio OR @pnIdEstudio IS NULL)  
 and  e.IdLaboratorio = @pnIdLaboratorio
     
 SET NOCOUNT OFF;    
END